package com.xieyong.leetcode;

import java.util.Arrays;

public class Leetcode3487 {
    public static void main(String[] args) {
        Leetcode3487 leetcode3487 = new Leetcode3487();
        int[] nums = new int[0];
        int i = leetcode3487.maxSum(nums);
        System.out.println(i);

    }


    public int maxSum(int[] nums) {
        int res = 0;
        int n = nums.length;
        Arrays.sort(nums);
        if (nums[n - 1] < 0) {
            return nums[n - 1];
        }
        res += nums[n - 1];
        for (int i = n - 2; i >= 0; i--) {
            if (nums[i] > 0 && nums[i] != nums[i + 1]) {
                res += nums[i];
            }
        }
        return res;
    }
}
